package com.example.springboot.controller;

import com.example.springboot.common.Result;
import com.example.springboot.controller.request.BorrowPageRequest;
import com.example.springboot.entity.ReturnBook;
import com.example.springboot.service.impl.ReturnBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/returnBook")
public class ReturnBookController {


    @Autowired
    ReturnBookService returnBookService;



    //获取
    @GetMapping("/{id}")
    public Result getById(@PathVariable Integer id){
        ReturnBook returnBooks = returnBookService.getById(id);
        return Result.success(returnBooks);
    }

    //单个删除
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Integer id) {
        returnBookService.deleteById(id);
        return Result.success();
    }


    //   查询全部
    @GetMapping("/list{id}")
    public Result list(@PathVariable Integer id) {
        returnBookService.getByIds(id);
        return Result.success();
    }


    //    分页查询
    @GetMapping("/page")
    public Result page(BorrowPageRequest borrowPageRequest) {
        return Result.success(returnBookService.page(borrowPageRequest));
    }
}
